<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>办公系统</title>
<link href="${ctx}/css/main/base.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="${ctx}/scripts/sys/calendar.js"></script>
</head>
<body class="m_r">
<form action="user_modify.action" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab_m left">
  <tr>
    <td colspan="2" class="zctop left"><span class="font14 zc_bt">个人资料</span></td>
  </tr>
  <tr>
    <td colspan="2" class="bg1 font14">基本信息</td>
  </tr>
  <tr>
    <td class="bg5 right">姓名：</td>
    <td>${user.userName}</td>
  </tr>
   <tr>
    <td class="bg5 right">身份证号：</td>
    <td><input type="text" id="userCard" name="user.userCard" value="${user.userCard}" onblur="showBirthday(document.all.userCard.value);" class="fl_l"/><div id="code"></div></td>
  </tr>
  <tr>
    <td class="bg5 right">性别：</td>
    <td><select name="user.userSex">
                <option value=""></option>
                <option value="0" <s:if test="user.userSex == 0">selected</s:if> >男</option>
                <option value="1" <s:if test="user.userSex == 1">selected</s:if>>女</option>
                </select></td>
  </tr>
  <tr>
    <td class="bg5 right">生日：</td>
    <td><input type="text" name="user.userBirthday" id="birthday" value="<s:date name="user.userBirthday" format="yyyy-MM-dd"/>"/>
    <img src="${ctx}/images/main/calendar.gif" align="absMiddle" border="0" style="cursor:hand" onclick="setday(this,document.all.birthday)"></td>
  </tr>
  <tr>
    <td colspan="2" class="bg1 font14">联系方式</td>
  </tr>
  <tr>
    <td class="bg5 right">手机：</td>
    <td><input type="text" name="user.userPhone" value="${user.userPhone}" class="fl_l"/><div id="errPhone"></div></td>
  </tr>
  <tr>
    <td class="bg5 right">电子邮件：</td>
    <td><input type="text" name="user.userEmail" value="${user.userEmail}" class="fl_l"/><div id="errEmail"></div></td>
  </tr>
  <tr>
  <input type="hidden" name="user.userId" value="${user.userId}"/>
  <input type="hidden" name="user.userLogin" value="${user.userLogin}"/>
  <input type="hidden" name="user.userPwd" value="${user.userPwd}"/>
  <input type="hidden" name="user.userOrder" value="${user.userOrder}"/>
  <input type="hidden" name="user.userName" value="${user.userName}"/>
  <input type="hidden" name="user.userSpell" value="${user.userSpell}"/>
  <input type="hidden" name="user.userAlias" value="${user.userAlias}"/>
  <input type="hidden" name="user.roleId" value="${user.roleId}"/>
  <input type="hidden" name="user.roleIdOther" value="${user.roleIdOther}"/>
  <input type="hidden" name="user.deptId" value="${user.deptId}"/>
  <input type="hidden" name="user.deptIdOther" value="${user.deptIdOther}"/>
  <input type="hidden" name="user.userFlag" value="${user.userFlag}"/>
  <input type="hidden" name="user.userMemo" value="${user.userMemo}"/>
    <td colspan="2" class="hei_1 center"><input type="button" onclick="modifyInfo();" value="修 改" class="log_f zc_b">
	<input type="button" value="返 回" class="log_f zc_b">	</td>
  </tr>
</table>
</form>
</body>
</html>
<script type="text/javascript" src="${ctx}/scripts/commons/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="${ctx}/scripts/commons/validation.js"></script>
<script type="text/javascript">
<!--
function inntBycode(){
	var code = document.getElementById("userCard").value;
	if(code.length > 0){
				var innitUrl = "${ctx}/user/user!innitByCode.action";
				var parm = "user.userCard=" 
							+ code
							+ "&time=" 
							+ new Date().getTime();
				$.ajax(
				{
					type:"POST",
					url:innitUrl,
					data:parm,
					dataType:"json",
					success:function(json) {
						var user = json.baseUser;
					if(user.userBirthday == null || user.userSex == null){
						document.getElementById("code").innerHTML = "请正确输入身份证号码!";
					}else{
						document.getElementById("birthday").value = user.userBirthday;
						document.getElementById("user.userSex").value = user.userSex;
					}
					
					},
					error:function(){
						alert("系统故障，添加分类失败！！！");
					}
				});
		}	
}

function modifyInfo(){
	var userPhone = document.getElementById("user.userPhone").value;
	var userEmail = document.getElementById("user.userEmail").value;
	if(userPhone.length > 0 && !isAllNumber(userPhone)){
		document.getElementById("errPhone").innerHTML = "<font color='red'> 正确填写手机号码!</font>";
		return false;
	}
	if(userEmail.length > 0 && isEmail(userEmail) == false){
		document.getElementById("errEmail").innerHTML = "<font color='red'> 正确填写电子邮箱!</font>";
		return false;
}
document.forms[0].submit();
}


//根据身份证，获得性别和出生年月
　　 function showBirthday(val)
　　 {
 	if((/^\d{18}|\d{17}[xX]{1}|\d{15}$/).test(val)){

		var birthdayValue;
	　　 if(15==val.length)
	　　 { //15位身份证号码
	　　 birthdayValue = val.charAt(6)+val.charAt(7);
	　　 if(parseInt(birthdayValue)<10)
	　　 {
	　　 birthdayValue = '20'+birthdayValue;
	　　 }
	　　 else
	　　 {
	　　 birthdayValue = '19'+birthdayValue;
	　　 }
	　　 birthdayValue=birthdayValue+'-'+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11);
	　　 if(parseInt(val.charAt(14)/2)*2!=val.charAt(14))
	    document.getElementById("user.userSex").value=0;
	    else
		document.getElementById("user.userSex").value=1;
		document.getElementById("user.userBirthday").value= birthdayValue;
	　　 }
	　　 if(18==val.length)
	　　 { //18位身份证号码
	　　 birthdayValue=val.charAt(6)+val.charAt(7)+val.charAt(8)+val.charAt(9)+'-'+val.charAt(10)+val.charAt(11) 
	　　 +'-'+val.charAt(12)+val.charAt(13);
	　　 if(parseInt(val.charAt(16)/2)*2!=val.charAt(16))
	    document.getElementById("user.userSex").value=0;
	    else
		 document.getElementById("user.userSex").value=1;
	　　 document.getElementById("user.userBirthday").value= birthdayValue;
	　　 }
	}else{
		document.getElementById("code").innerHTML = "<font color='red'> 请正确输入身份证号码!</font>";
	}
　　 }
//-->
</script>